<?php
namespace BLL\DataModel;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of DataContractHelper
 *
 * @author David Wu
 */
class DataContractHelper {
    
    public $dataContract;
    
    public function loadFromConfig($configName=null){
//        if(!$configName){
//            throw new \Exception("Name needed to load data contract config file.");
//        }
        $path = str_replace(array("\\","/"), DIRECTORY_SEPARATOR, $GLOBALS["AppConfig"]["dataContract"]);
        if (!strrchr($path, DIRECTORY_SEPARATOR)) {
            $path = $path . DIRECTORY_SEPARATOR;
        }
        $filename=  app_path().DIRECTORY_SEPARATOR.$path.$configName.".json";
        if (file_exists($filename)) {
            $this->configFile = $configName;
            $str = file_get_contents($filename);
            $this->dataContract = json_decode($str,true);
        } else {
            throw new \Exception("Failed to find load data contract config file:" . $configName);
        }
    }
    
    
    
    
}
